package com.shbaiche.bifenba.ui.base;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.shbaiche.bifenba.R;
import com.umeng.analytics.MobclickAgent;

import cn.droidlover.xdroid.base.XActivity;
import cn.droidlover.xdroid.base.XLazyFragment;

/**
 * Created by Administrator on 2018/7/22 0022.
 */

public abstract class BaseActivity extends XActivity {
    //public abstract void doClick(View view);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setToolbar();
    }

    public abstract void setToolbar();

    protected void initToolbar(Toolbar toolbar, String title) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.btn_back);
        getSupportActionBar().setTitle("");
        if (title != null) {
            TextView tvTitle = (TextView) toolbar.findViewById(R.id.toolbar_tv_title);
            tvTitle.setText(title);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
